home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / Mem_DumpTrace.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-22  |  2.0 KB  |  74 lines

  1. /* 
  2.  * Mem_DumpTrace.c --
  3.  *
  4.  *    Source code for the "Mem_DumpTrace" library procedure.  See memInt.h
  5.  *    for overall information about how the allocator works.
  6.  *
  7.  * Copyright 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/Mem_DumpTrace.c,v 1.1 88/05/20 15:49:20 ouster Exp $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21. #define MEM_TRACE 1
  22. #include "memInt.h"
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * Mem_DumpTrace --
  28.  *
  29.  *    Dump the allocation trace records for the given size block.  If
  30.  *    the size is specified as -1 then all trace records for all size
  31.  *    blocks are dumped.
  32.  *
  33.  * Results:
  34.  *    None.
  35.  *
  36.  * Side effects:
  37.  *    None.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41.  
  42. void 
  43. Mem_DumpTrace(blockSize)
  44.     int    blockSize;
  45. {
  46.     register MemTraceElement    *trPtr;
  47.     int                i, j;
  48.  
  49.     for (i = 0, trPtr = memTraceArray; i < memNumSizesToTrace; i++, trPtr++) {
  50.     if ((trPtr->traceInfo.size != blockSize) && (blockSize != -1)) {
  51.         continue;
  52.     }
  53.     if (!(trPtr->traceInfo.flags & MEM_STORE_TRACE) ||
  54.         (trPtr->traceInfo.flags & MEM_TRACE_NOT_INIT)) {
  55.         continue;
  56.     }
  57.  
  58.     (*memPrintProc)(memPrintData, "Trace for size = %d:\n", 
  59.                       trPtr->traceInfo.size);
  60.     (*memPrintProc)(memPrintData, "Caller-PC      Num-blocks  \n");
  61.     for (j = 0; j < MAX_CALLERS_TO_TRACE; j++) {
  62.         if (trPtr->allocInfo[j].numBlocks == 0) {
  63.         break;
  64.         }
  65.         (*memPrintProc)(memPrintData, "%8x         %6d\n", 
  66.                       trPtr->allocInfo[j].callerPC,
  67.                       trPtr->allocInfo[j].numBlocks);
  68.     }
  69.     if  (blockSize != -1) {
  70.         break;
  71.     }
  72.     }
  73. }
  74.